#include<stdio.h>

union 
{
	int i;
	char c;
	float f;
	double lf;
}t;

int main()
{
	char elementType;
	printf("请输入数据类型：");
	scanf("%c",&elementType);
	switch (elementType)
	{
		case 'i':scanf("%d",&t.i);break;
		case 'c':scanf("%c",&t.c);break;
		case 'f':scanf("%f",&t.f);break;
		case 'lf':scanf("%lf",&t.lf);break;
		default:printf("error input!\n");break;	
	}
	switch (elementType)
	{
		case 'i':printf("%d\n",t.i);break;
		case 'c':printf("%c\n",t.c);break;
		case 'f':printf("%f\n",t.f);break;
		case 'lf':printf("%lf\n",t.lf);break;
		default:printf("error input!\n");break;	
	}
	return 0;
}
